<?php

namespace app\admin\controller;

use think\Request;
use app\admin\model\Message as mMessage;

class Message extends Base
{

    /*管理页面加载
     * */
    public function index()
    {
        return $this->fetch();
    }
    /*列表数据调用
     * */
    public function lists(Request $request)
    {
        if ($request->isPost()) {
            //判断是否有条件查询
            $where = $request->has('where')?$request->param()['where']:[];
            //获取当前页码
            $page = $request->param('page');
            //获取每页显示条数
            $limit = $request->param('limit');
            //过滤空值项
            $where = array_filter($where);

            return mMessage::mAll($page,$limit,$where);
        }else{
            return return_json(1,'请求错误！');
        }
    }

    /*
     * 删除
     * */
    public function del(Request $request){
        if ($request->isPost()){
            $data = $request->param()['data'];
            return mMessage::mDel($data);
        }else{
            $this->error('请求参数错误','Index/welcome');
        }
    }
    /*状态修改
     * */
    public function status(Request $request){
        if ($request->isPost()){
            $data = $request->param()['data'];
            return mMessage::mStatus($data);
        }else{
            $this->error('请求参数错误','Index/welcome');
        }
    }

}
